package com.codelife.suanfa;

/**
 * @ClassName Demo7
 * @Description TODO
 * @Date 2019/10/25 14:47
 * @Version 1.0
 **/

//【程序7】   题目：输入一行字符，分别统计出其中英文字母、空格、数字和其它字符的个数。
public class Demo7 {
    public static void main(String[] args) {

        String coke="446432424 sdadadsaASDASdadoiahdashda &%%#$^&*$%@%@";
        char[] chars = coke.toCharArray();

        int yingwen=0;
        int kongge=0;
        int shuzi=0;
        int qita=0;

        for (int i=0;i<chars.length;i++){
            if(('a'<=chars[i]&&'z'>=chars[i])||('A'<=chars[i]&&'Z'>=chars[i])){
                yingwen++;
                continue;
            }
            if(('0'<=chars[i]&&'9'>=chars[i])){
                shuzi++;
                continue;
            }
            if(' '==chars[i]){
                kongge++;
                continue;
            }else {
                qita++;
            }

        }
        System.out.println(yingwen);
        System.out.println(shuzi);
        System.out.println(kongge);
        System.out.println(qita);
    }
}
